package main;

import graph.GenericGraph;
import graph.Node;
import graphAndAnswer.GoolkateGraph;
import graphAndAnswer.GraphWithInnerStart;
import graphAndAnswer.ModuleHandleidingGraph;
import graphAndAnswer.MultipleStartPointsGraph;

import interfaces.BuildGraph;

import java.util.ArrayList;


import classesPERT.PERTNetwerk;

public class Main {

	public static void main(String[] args) {

		// make a graph
		// a few already made graphbuilders
		 BuildGraph graphBuilder = new ModuleHandleidingGraph();
		// BuildGraph graphBuilder = new GraphWithInnerStart();
		// BuildGraph graphBuilder = new GoolkateGraph();
		//BuildGraph graphBuilder = new MultipleStartPointsGraph();

		// make new commands
		PERTNetwerk pertCommands = new PERTNetwerk();

		// get the graph
		GenericGraph graph = graphBuilder.getGraph();
		// extra graph is need because topologicalSorting changes the graph
		GenericGraph graphBackup = graphBuilder.getGraph();

		// get a sorted list
		ArrayList<Node> sortedList = pertCommands.topologicalSorting(graph);
		// calculate times using an original graph and the sorted list of that
		// graph
		pertCommands.calculateEarliest(graphBackup, sortedList);
		pertCommands.calculateLatest(graphBackup, sortedList);

		// print
		for (Node node : graphBackup.getNodes()) {
			System.out.println(node.toString());
		}
	}
}
